﻿<?xml version="1.0" encoding="utf-8"?>

<dbTestFixture
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="file:/C:/TestFileSchema2.xsd">
  <usage>
    <![CDATA[ 
    Function introduction:
       1. Performance test for stored procedure and sql.
       2. Unit test for stored procedure and sql. 
  
    Remark:
      1. Argument size:
         For argument is variable-length data type, such as char or varchar, if its direction is Output or Return or AnonymousOutput, size attribute is mandatory. 
         if their direction is InputOutput, size attribute is also recommended to assign.
      2. exportRecordCount must be in -1, 0, other integer value greater than 0. 
             If =-1, it will output all records 
             if =0, it will not output any record
             if =Value, it will output the given number of records 
      3. For Query SQL, the name of return argument can be any string.
      4. In SQL programming perspective, there are two kinds of database whether the database supports anonymous-output argument or not.
         e.g. Oracle does not allow anonymous-output in stored procedure, because all resultsets of a stored procedure must be carried by those explicited arguments. 
         MS SQL Server and MySQL are anonymous-output supported database.
         Caution: 
           For database supporting anonymous-output, the order of each argument declaration is very important because the resultsets are retrieved according to the position of argument declaration. 
		     e.g. In MS SQL Server, if there are anonymous-output resultsets, the anonymous-output arguments must locate prior to real output arguments. 
           For database not supporting anonymous-output, the order of each argument declaration is not relevant at all. Because the resultsets are retrieved according to their argument names.
    ]]>
  </usage>
  <globalSetting exportRecordCount="200" wrapStringByCDATA="false" >
    <dbConnection connectionName="db1"
            connectionString="Data Source=localhost\sqlexpress;Initial Catalog=Test1_Demo_Db;Integrated Security=True"
            providerName="System.Data.SqlClient" />
    <dbConnection connectionName="excel_refer_file"
            connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\excel_testpoints_ref.xls;Extended Properties='Excel 8.0;HDR=YES;IMEX=1'"
            providerName="Microsoft.Jet.OLEDB.4.0" />
  </globalSetting>

  <procDeclarations>
  </procDeclarations>

  
  <sqlDeclarations>
    

    <sqlDeclaration alias="Sql_GetExcelReferenceData" dbConnection="excel_refer_file">
      <remark> Get all test points from excel</remark>
      <sql>
        <![CDATA[ Select X, Y, Expected_Result from [Sheet1$]  ]]>
      </sql>
      <arguments>
        <argument name="RETURN_Table" direction="Return"  type="XLS_RECORDSET"  />
      </arguments>
      
     
    </sqlDeclaration>


    <sqlDeclaration alias="Sql_InsertRefData" dbConnection="db1">
      <remark>insert excel reference data into sql server table of dbo.T_Test1_Helper, it is a helper sql,  to test SQL SERVER function of fun_add_values </remark>
      <sql>
        <![CDATA[ insert into [dbo].[T_FUN_ADD_VALUES_HELPER] (F_X, F_Y, F_Expected_Result) values (@x,@y,@expected_Result) ;]]>
      </sql>
      <arguments>
        <argument name="@x" direction="Input" type="MSSQL_INT"/>
        <argument name="@y" direction="Input" type="MSSQL_INT"/>
        <argument name="@expected_Result" direction="Input" type="MSSQL_INT"/>
      </arguments>
    </sqlDeclaration>

    <sqlDeclaration alias="Sql_GetTestResult" dbConnection="db1">
      <sql>select dbo.fun_add_values_helper() </sql>
      <arguments>
        <argument name="@result" direction="Return" type="MSSQL_INT"/>
      </arguments>
    </sqlDeclaration>
    
    <sqlDeclaration alias="sql_get_const_number" dbConnection="db1">
      <remark>to get constant number from database server</remark>
      <sql><![CDATA[select @constant]]></sql>
      <arguments>
        <argument name="@constant" direction="Input" type="MSSQL_INT"/>
        <argument name="@result" direction="Return" type="MSSQL_INT"/>
      </arguments>
    </sqlDeclaration>
  </sqlDeclarations>

 
  <unitTestCases>
    <unitTestCase testCaseName="UT_Demo1" assertion="StrictEqual" testInSandbox="true">
      <setup>
        <dataPumpAction>
          <remark>Insert all test points insert sql server from excel </remark>
          <pumpSourceStatement statementAlias="Sql_GetExcelReferenceData" outputArgument="RETURN_Table">
          </pumpSourceStatement>
          <pumpDestinationStatement statementAlias="Sql_InsertRefData">
            <inputArguments>
              <argument name="@x" value="X" valueIsReferFieldName="true" />
              <argument name="@y" value="Y" valueIsReferFieldName="true"/>
              <argument name="@expected_Result" value="Expected_Result" valueIsReferFieldName="true"/>
            </inputArguments>
          </pumpDestinationStatement>
        </dataPumpAction>
      </setup>
      <targetResultset statementAlias="Sql_GetTestResult" outputArgument="@result">
      </targetResultset>
      <referenceResultset statementAlias="sql_get_const_number" outputArgument="@result">
        <inputArguments>
          <argument name="@constant" value="0"/>
        </inputArguments>
      </referenceResultset>
    </unitTestCase>

 
 
  </unitTestCases>

</dbTestFixture>